package com.chuanyang.driverh.mainorder;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.base.BaseTitleActivity;
import com.chuanyang.driverh.utils.ActivityUtil;

public class MatchOrderResultActivity extends BaseTitleActivity {

    private ImageView iv_result;
    private TextView tv_result;
    private TextView tv_notice;
    private TextView tv_look;
    private TextView tv_cancle;
    private Intent intent;
    private String orderId;
    private String orderNum;
    private String opreateType;

    @Override
    protected int getContentResId() {
        return R.layout.order_act_matchorderresult;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

        iv_result = (ImageView) findViewById(R.id.iv_act_result);
        tv_result = (TextView) findViewById(R.id.tv_act_result);
        tv_notice = (TextView) findViewById(R.id.tv_act_notice);
        tv_look = (TextView) findViewById(R.id.tv_act_lookorder);
        tv_cancle = (TextView) findViewById(R.id.tv_act_cancle);
    }


    @Override
    public void initData() {
        getTitleTextView().setText("订单回执");
        setBackImg();
        intent = getIntent();

        //获取操作的类型    "2"匹配订单，显示抢单，可以搁置，可以放弃      "3"专线订单，不显示搁置和倒计时 此处没有竞价订单
        //"4"分配订单  不能拒绝
        if (!TextUtils.isEmpty(intent.getStringExtra("orderId"))) {
            orderId = intent.getStringExtra("orderId");
        }
        if (!TextUtils.isEmpty(intent.getStringExtra("orderNum"))) {
            orderNum = intent.getStringExtra("orderNum");
        }
        if (!TextUtils.isEmpty(intent.getStringExtra("opreateType"))) {
            opreateType = intent.getStringExtra("opreateType");
        }
        iv_result.setImageResource(R.mipmap.order);
        if (opreateType.equals("2")) {
            tv_result.setText("您已申请订单Y" + orderNum);
            tv_notice.setText("正在等待货主确认，请耐心等待！");
        }
        else {
            tv_result.setText("您已申请订单Y" + orderNum);
            tv_notice.setText("请注意取货时间，提前安排车辆前往运输！");
        }




    }

    @Override
    protected void initListener() {
        tv_look.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.tv_act_lookorder:
                //startActivity(OrderDetailActivity.class, orderId);
                ActivityUtil.startActivity(activityContext,new Intent(activityContext,NewOrderDetailActivity.class).putExtra("data", orderId));
                finish();
                break;
//            case  R.id.tv_act_cancle:
//                ToastUtils.showShort(getApplicationContext(),"撤销订单");
            // break;
        }
    }
}
